package org.lds.scheduled.job.worker.scheduler.service;

import org.lds.scheduled.job.common.model.AddJobModel;
import org.quartz.JobDetail;
import org.quartz.Trigger;

import java.util.Date;
import java.util.Map;

public interface SchedulerService {
    /**
     * 新建job
     * @param jobDataMap
     * @param jobName
     * @param groupName
     */
    JobDetail newJob(Map<String, Object> jobDataMap, String jobName, String groupName);
    /**
     * 删除job
     */
    boolean deleteJob(String jobName, String groupName);

    /**
     * 触发规则: 固定频率（秒）
     */
    Trigger newTrigger(String triggerName, String groupName, int intervalInSeconds);
    /**
     * 触发规则: CRON
     */
    Trigger newTrigger(String triggerName, String groupName, String cron);
    Trigger newTrigger(String triggerName, String groupName, int type, String content);
    /**
     * 更新触发规则
     */
    Trigger updateTrigger(String triggerName, String triggerGroupName, int type, String content);

    /**
     * 使用触发器启动job
     * @param job
     * @param trigger
     */
    Date scheduleJob(JobDetail job, Trigger trigger);

    /**
     * 使用触发器启动或更新job
     */
    void scheduleJob(AddJobModel jobModel);
}
